<script type="text/javascript">
var app = {
	key : '<?php echo $id ?>',
}
//------------------------------------------------------------------------------------------- save
function saveBasic(form, evt){
	var msg = "";
	new Event(evt).stop();
	form = $(form);
		form.set('send', {url:'<?php echo site_url(array('dashboard','saveEditBasic'))?>',method :'post',
		 	onSuccess: function(responseText, responseXML){
				showBasic();
				box_basic.close()
			},
			onComplete: function(){

			},
			onFailure: function(xhr){
				var message = "Failed to save";
				failure(message);
			}
		});
		form.send();
	
	return false;
}
function saveAddress(form, evt){
	var msg = "";
	new Event(evt).stop();
	form = $(form);
		form.set('send', {url:'<?php echo site_url(array('dashboard','saveEditAddress'))?>',method :'post',
		 	onSuccess: function(responseText, responseXML){
				box_address.close();
				showAddress();
			},
			onComplete: function(){

			},
			onFailure: function(xhr){
				var message = "Failed to save";
				failure(message);
			}
		});
		form.send();
	
	return false;
}
function saveContact(form, evt){
	var msg = "";
	new Event(evt).stop();
	form = $(form);
		form.set('send', {url:'<?php echo site_url(array('dashboard','saveEditContact'))?>',method :'post',
		 	onSuccess: function(responseText, responseXML){				
				box_contact.close();
				showContact();
			},
			onComplete: function(){

			},
			onFailure: function(xhr){
				var message = "Failed to save";
				failure(message);
			}
		});
		form.send();
	
	return false;
}
//------------------------------------------------------------------------------------------- edit
function editBasic(){

	box_basic = new LightFace.Request({
		width:400,
		height:140,
		url: '<?php echo site_url(array('dashboard','editBasic'))?>',
		buttons: [
		  	{ title: 'Save', event: function() { saveBasic(this, event); }, color: 'blue' },
			{ title: 'Cancel', event: function() { this.close(); } }
		],
		title: 'Edit Basic Info',
		request: { 
		data: { 
				dt : app.key
			},
			method: 'post'
		},
	}).open();
}
function editAddress(key){
	var id = key;
	box_address = new LightFace.Request({
		width:400,
		height:70,
		url: '<?php echo site_url("dashboard/editAddress/")?>',
		buttons: [
		  	{ title: 'Save', event: function() { saveAddress(this, event); }, color: 'blue' },
			{ title: 'Cancel', event: function() { this.close(); } }
		],
		title: 'Edit Address',
		request: { 
		data: { 
				dt : app.key
			},
			method: 'post'
		},
	}).open();
}
function editContact(){
	box_contact = new LightFace.Request({
		width:400,
		height:90,
		url: '<?php echo base_url()."dashboard/editContact/"?>',
		buttons: [
		  	{ title: 'Save', event: function() { saveContact(this, event); }, color: 'blue' },
			{ title: 'Cancel', event: function() { this.close(); } }
		],
		title: 'Edit Contact',
		request: { 
		data: { 
				dt : app.key
			},
			method: 'post'
		},
	}).open();

}
//-------------------------------------------------------------------------------------------------------- show
function showContact() {
	var myRequest = new Request({
		url: '<?php echo base_url()."dashboard/showContact/"?>'+app.key,
		method: 'post',
		onSuccess : function(responseText){
			$('showContact').innerHTML = responseText;
		}
	}).send();
}
function showBasic() {
	var myRequest = new Request({
		url: '<?php echo base_url()."dashboard/showBasic/"?>'+app.key,
		method: 'post',
		onSuccess : function(responseText){
			$('showBasic').innerHTML = responseText;
		}
	}).send();
}
function showAddress() {
	var myRequest = new Request({
		url: '<?php echo base_url()."dashboard/showAddress/"?>'+app.key,
		method: 'post',
		onSuccess : function(responseText){
			$('showAddress').innerHTML = responseText;
		}
	}).send();
}
//-------------------------------------------------------------------------------------------------------- domready
window.addEvent('domready',function(){
	showContact();
	showBasic();
	showAddress();
});
</script>
<table bgcolor="#ccc" width="575" border="0" cellpadding="1" cellspacing="0">
<tr><td>
	<table width="575" border="0" cellspacing="10" cellpadding="0" bgcolor="#fff">
	
	<?php
  foreach ($member->result() as $row): 
  	if($row->thumbs=="" || $row->thumbs==false){
		$row->thumbs = site_url("images/nopicture.jpg");
	} else {
		$que = $this->db->query("select thumbs from member where id_member='$row->id_member' limit 1");
		foreach ($que->result() as $res):
			$row->thumbs = site_url(array('dashboard','loadThumbs',$row->id_member));
		endforeach;
	}
  ?>
	<tr>
    <td colspan="2" align="left" valign="top">
		<table width="100%" border="0" cellpadding="0" cellspacing="0">
     <tr>
      <td><b>Profile Picture</b></td>
      <td><div align="right">
    <a class="uiButton uiAdd" href="<?php echo site_url('dashboard/addEditProfile')?>">Edit</a></div></td>
     </tr>
    </table>
      <hr size="1" color="#CCCCCC" /></td>
  </tr>
  <tr>
    <td width="9%" align="left" valign="top"><label for="images"></label></td>
    <td align="left" valign="top">
    <img src="<?php echo $row->thumbs?>" />
    </td>
  </tr>
  <?php endforeach;?>
  
  
  
  <tr>
    <td colspan="2" align="left" valign="top">
		<table width="100%" border="0" cellpadding="0" cellspacing="0">
     <tr>
      <td><b>Basic Info</b></td>
      <td><div align="right">
    <a class="uiButton uiAdd" href="javascript: editBasic()">Edit</a></div></td>
     </tr>
    </table>
      <hr size="1" color="#CCCCCC" /></td>
  </tr>
   <tbody id="showBasic"></tbody>
  
   
  <tr>
    <td colspan="2" align="left" valign="top">
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
     <tr>
      <td><b>Address</b></td>
      <td><div align="right">
    <a class="uiButton uiAdd" href="javascript: editAddress()">Edit</a></div></td>
     </tr>
    </table>
	<hr size="1" color="#CCCCCC"/></td>
  </tr>
  	<tbody id="showAddress"></tbody>
  
    
  <tr>
    <td colspan="2" align="left" valign="top">
    <table width="100%" border="0" cellpadding="0" cellspacing="0">
     <tr>
      <td><b>Contact</b></td>
      <td><div align="right">
    <a class="uiButton uiAdd" href="javascript: editContact()">Edit</a></div></td>
     </tr>
    </table>
    <hr size="1" color="#CCCCCC"></td>
  </tr>
  <tbody id="showContact"></tbody>
  
  
</table>
	
</td></tr>
</table>